package com.wx.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wx.entity.IndexBanner;
import com.wx.entity.IndexCategory;
import com.wx.entity.IndexGoods;
import com.wx.entity.IndexNotice;
import com.wx.entity.IndexNoticeDetail;
import com.wx.mapper.IndexBannerMapper;
import com.wx.mapper.IndexCategoryMapper;
import com.wx.mapper.IndexGoodsMapper;
import com.wx.mapper.IndexNoticeMapper;
import com.wx.service.ShopService;

@Service
public class ShopServiceImpl implements ShopService {

	@Autowired
	private IndexCategoryMapper indexCategoryMapper;

	@Autowired
	private IndexBannerMapper indexBannerMapper;

	@Autowired
	private IndexNoticeMapper indexNoticeMapper;

	@Autowired
	private IndexGoodsMapper indexGoodsMapper;

	@Override
	public List<IndexCategory> selectAllCategory() {
		return indexCategoryMapper.selectAll();
	}

	@Override
	public List<IndexBanner> selectAllBanner() {
		return indexBannerMapper.selectAll();
	}

	@Override
	public List<IndexNotice> selectAllNotice() {
		return indexNoticeMapper.selectAll();
	}

	@Override
	public IndexNoticeDetail findNoticeDetail(Integer id) {
		return indexNoticeMapper.findNoticeDetail(id);
	}

	@Override
	public List<IndexGoods> selectAll() {
		return indexGoodsMapper.selectAll();
	}

	@Override
	public List<IndexGoods> selectByRecommendStatus(Integer recommendStatus, Integer categoryId, String nameLike,
			Integer page, Integer pageSize, Boolean pintuan) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("recommendStatus", recommendStatus);
		map.put("categoryId", categoryId);
		map.put("nameLike", nameLike);
		Integer firstIndex = null;
		Integer lastIndex = null;
		if (page != null) {
			// 从第几条数据开始
			firstIndex = (page - 1) * pageSize;
			// 到第几条数据结束
			lastIndex = page * pageSize;
		}
		map.put("firstIndex", firstIndex);
		map.put("lastIndex", lastIndex);
		map.put("pintuan", pintuan);
		return indexGoodsMapper.selectByRecommendStatus(map);
	}

}
